using System;
using System.Data;

using SqlHelperForCry.Common;

namespace Torch.WL.Entity
{
    [Table("Tb_Weibo", "wbId", "Torch.WL.ConnectionString")]
    public class Tb_Weibo : Info
    {
        #region SQL column name consts
        public const string SQLCOL_WBID = "wbId";
        public const string SQLCOL_WEIBO = "weibo";
        public const string SQLCOL_WEIBO_IMAGES = "weibo_images";
        public const string SQLCOL_SUBMITTIME = "submitTime";
        public const string SQLCOL_CREATETIME = "createTime";
        #endregion


        #region Contructors
        /// <summary>
        /// Construct empty entity
        /// </summary>
        public Tb_Weibo() { }

        /// <summary>
        /// Construct entity by primary key, other fields will be assigned by 
        /// "Load" method.
        /// </summary>
        public Tb_Weibo(int wbId)
        {
            this.wbId = wbId;
        }
        #endregion

        public override void Init(DataRow row)
        {
            wbId = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_WBID]);
            weibo = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_WEIBO]);
            weibo_images = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_WEIBO_IMAGES]);
            submitTime = (DateTime)ObjectType.DateTimeTypeHelper.Read(row[SQLCOL_SUBMITTIME]);
            createTime = (DateTime)ObjectType.DateTimeTypeHelper.Read(row[SQLCOL_CREATETIME]);
        }

        #region Properties
        #region Property <int> wbId
        [Property("wbId", 4, SqlDbType.Int, true, true)]
        public int wbId
        {
            get { return _wbId; }
            set { _wbId = value; }
        }
        private int _wbId = int.MinValue;
        #endregion

        #region Property <string> weibo
        [Property("weibo", 1000, SqlDbType.VarChar, false, false)]
        public string weibo
        {
            get { return _weibo; }
            set { _weibo = value; }
        }
        private string _weibo = null;
        #endregion

        #region Property <string> weibo_images
        [Property("weibo_images", 2000, SqlDbType.VarChar, false, false)]
        public string weibo_images
        {
            get { return _weibo_images; }
            set { _weibo_images = value; }
        }
        private string _weibo_images = null;
        #endregion

        #region Property <DateTime> submitTime
        [Property("submitTime", 16, SqlDbType.DateTime, false, false)]
        public DateTime submitTime
        {
            get { return _submitTime; }
            set { _submitTime = value; }
        }
        private DateTime _submitTime = DateTime.MinValue;
        #endregion

        #region Property <DateTime> createTime
        [Property("createTime", 16, SqlDbType.DateTime, false, false)]
        public DateTime createTime
        {
            get { return _createTime; }
            set { _createTime = value; }
        }
        private DateTime _createTime = DateTime.MinValue;
        #endregion
        #endregion


        public bool LoadByIdentity(int wbId)
        {
            return DataAccess.SelectByIdentity(this, Convert.ToInt64(wbId));
        }


        public bool DeleteByIdentity()
        {
            return DataAccess.DeleteByIdentity(this);
        }
    }
}
